// store/index.js
import { create } from 'zustand';
import { Api, requestFn } from '@/api/api.js'
const useCountStore = create((set) => ({
    count: 0,
    increment: () => set((state) => ({ count: state.count + 1 })),
    decrement: () => set((state) => ({ count: state.count - 1 })),
    DbList: [],
    fetchDbList: async () => {
        const res = await requestFn(Api.db, 'get');

        console.log(res, "zustand request");
        set({
            DbList: res
        })
    },
    treeList:{},
    fetchTreeList: async (params) => {
        const res = await requestFn(Api['Login_loginByPwd'], 'post',{
            app_id: "JTM",
login_name: "13052503315",login_pwd: "123456",
...params
        });

        console.log(res, "zustand request");
        set({
            treeList: res
        })
    },
treeList2:[],
  fetchTreeList2: async (params) => {
        const res = await requestFn(Api['DeptInfo_treeList'], 'post',{
            app_id: "JTM",
login_name: "13052503315",login_pwd: "123456",
...params
        });

        console.log(res, "zustand request");
        set({
            treeList2: res
        })
    },
    // DeptInfo_treeList
}));

export default useCountStore;